package com.whoimi.admin.rest;

import com.whoimi.common.ResultInfo;
import com.whoimi.admin.entity.vo.VisitStatsVO;
import com.whoimi.admin.entity.vo.VisitTrendVO;
import com.whoimi.admin.service.LogService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @author whoimi
 * @since 2025-07-28
 **/
@RestController
@RequestMapping("/api/v1/logs")
public class LogRest {
    @Resource
    private LogService logService;
    @GetMapping("/visit-trend")
    public ResultInfo<VisitTrendVO> getVisitTrend(@RequestParam String startDate, @RequestParam String endDate) {
        LocalDate start = LocalDate.parse(startDate);
        LocalDate end = LocalDate.parse(endDate);
        VisitTrendVO data = logService.getVisitTrend(start, end);
        return ResultInfo.ok(data);
    }

    @GetMapping("/visit-stats")
    public ResultInfo<VisitStatsVO> getVisitStats() {
        VisitStatsVO result = logService.getVisitStats();
        return ResultInfo.ok(result);
    }
}
